<?php

	$id = $_GET['id'];
	
	include("TSPlanEstudio.php");	
	$PE = new TSPlanEstudio();
	$RESULT = $PE->cargarPlanes();
	$COUNT =  mysql_num_rows($RESULT);
	
	include("TDGMostrarPE.php");
	$DataGateway = new TDGMostrarPE();
?>

<html>
    <head>
		<link href="css/estilos.css" rel="stylesheet" type="text/css" />  
		<title>Bit&aacute;cora Electr&oacute;nica</title>
    </head>
    <body>
        <div id="pagina">
           
			<?php include ("header.php");?> 
			<!-- fin de header -->
			
            <div id="menucontainer">
                    <ul id="menu">
                            <li><a href="index.php">Home</a></li>
							<li><a href="index.php">Planes Estudio</a>
								<ul>
									<?php
									if($COUNT > 0){
										while($row = mysql_fetch_array($RESULT))
										{
									?>
										<li><a href="TSMostrarPE.php?id=<?php echo $row['id']?>"><?php echo $row['nombre'];?> </a></li>
									<?php 
										}}
									?>
								</ul>
							</li>
                    </ul>
            </div>
            <!-- fin menu -->
            <!-- fin menu -->

            <div id="contenido"> 
			    <h1> Informaci&oacute;n del Plan de Estudios</h1>
				<table>
					<?php 
						$resul = $DataGateway->cargarInfoPlan($id);
						$most = mysql_fetch_array($resul);
					?>
					<tr>
						<td><label> Nombre: </label></td>
						<td><label> <?php echo $most['nombre'] ?></label></td>
					</tr>
					<tr>
						<td><label> Vigencia: </label></td>
						<td><label> <?php 
										if($most['vigencia'] ==1)
											echo "vigente";
										else
											echo "no vigente";
									?>
							</label>
						</td>
					</tr>
					<tr>
						<td><label> Grado Acad&eacute;mico: </label></td>
						<td><label> <?php echo $most['gradoAcademico'] ?></label></td>					
					</tr>
					<tr>
						<td><label> Cr&eacute;ditos: </label></td>
						<td><label> <?php echo $most['creditos'] ?></label></td>
					</tr>
					<tr>
						<td><label> Descripci&oacute;n: </label></td>
						<td><label> <?php echo $most['descripcion'] ?></label></td>
					</tr>
				</table>
				<br/>
				<br/>
				<h1> Cursos del Plan de Estudios</h1>
				<table class = 'tabla_curr' align='center' border='1'>
					<tr>
						<td> Nombre </td>
						<td> SiglaCurso </td>
						<td> Semestre </td>						
						<td> Creditos </td>
						<td> Requisitos </td>
						<td> Contenido </td>
					</tr>
					<?php 
						$result = $DataGateway->cargarCursosPlan($id);
						$cont = mysql_num_rows($result);
						for($i=1; $i <= $cont; $i++){
							$mostrar = mysql_fetch_array($result);
					?>
					<tr>
						<td><?php echo $mostrar['nombre']; ?></td>
						<td><?php echo $mostrar['sigla']; ?> </td>
						<td><?php echo $mostrar['semestre']; ?> </td>
						<td><?php echo $mostrar['creditos']; ?></td>
						<td><?php 
								$result3 = $DataGateway->cargarRequisitosPlan($mostrar['sigla']);
								$cont3 = mysql_num_rows($result3);
								$row3 = mysql_fetch_array($result3);
							?>
							<select name="menu_Requisitos">
								<option value="0" selected>
								<?php
									if($cont3>0){
										echo $row3['siglaRequisitos'];
										$cont3 = $cont3 -1;
									}else{
										echo "-----------";
									}	
								?></option>							
							<?php							
								for($i2=1; $i2 <= $cont3; $i2++){									
									$row3 = mysql_fetch_array($result3);
							?>						 
								<option value="<?php echo $row3['siglaRequisitos']; ?>" > <?php echo $row3['siglaRequisitos']; ?> </option>																	
							</select>
							<?php
								}
							?>							
						</td>
						<td> <a href="TSPlanCurso.php?curso=<?php echo $mostrar['sigla']?>&id=<?php echo $id?>"> Ver Contenido </a> </td>
					</tr>
					<?php
						}
					?>
				</table>
			</div>
            <?php include ("footer.php");?> 
            <!-- fin footer -->

        </div>
	<!-- fin pagina -->
    </body>
</html>